package com.cnhis.drgs;

import com.cnhis.drgs.core.util.GeneratorUtil;
import com.cnhis.drgs.util.Util;
import com.cnhis.drgs.vo.KeyValue;
import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

public class Generator {

    @Test
    public void generator() {

        String ip = "127.0.0.1";
        String port = "3306";
        String username = "root";
        String password = "123456";
        String schema = "baomidou";

        //表名(多个之间逗号隔开)

        Map<String, String> map = new HashMap<>();

        map.put("sys", "t_user");

        for (Entry<String, String> entry : map.entrySet()) {

            String projectName = "D:\\mpro\\springboot-learning\\springboot-generator";
            String basePackage = "org.spring.springbootgenerator";
            String moduleName = entry.getKey();

            boolean reserveSchema = false;

            Map<String, Object> items = Util.getSimpleMap(
                    new KeyValue<>("model", true),
                    new KeyValue<>("dao", true),
                    new KeyValue<>("mapper", true),
                    new KeyValue<>("service", true),
                    new KeyValue<>("serviceImpl", true),
                    new KeyValue<>("controller", true));

            GeneratorUtil.generator(ip, port, username, password, schema, entry.getValue(), projectName, basePackage, moduleName, reserveSchema, items);

        }


    }


    @Test
    public void test() {

//        String property = System.getProperty("user.dir");
//
//        System.out.println("replace="+property.replace("\\", "\\\\"));
//
//        System.out.println(this.getClass().getPackage().getName());

    }


}
